package com.affectu.dao;

import org.hibernate.cfg.ImprovedNamingStrategy;

/**
 * Oct 17, 2008
 * 
 * @author daniel nathan
 */
public class AffectuTableName extends ImprovedNamingStrategy {

	private static final long serialVersionUID = 1810098355580544322L;

	private String currentTablePrefix;

	@Override
	public String classToTableName(String className) {
		currentTablePrefix = className.substring(0, 3).toUpperCase() + "_";
		return "T" + currentTablePrefix + tableName(className);
	}

	@Override
	public String propertyToColumnName(String propertyName) {
		return currentTablePrefix + addUnderscores(propertyName).toUpperCase();
	}

	@Override
	public String columnName(String columnName) {
		return addUnderscores(columnName).toUpperCase();
	}

	@Override
	public String tableName(String tableName) {
		return addUnderscores(tableName).toUpperCase();
	}
}
